<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The EvPeriodic class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="evloop.verify.html">EvLoop::verify</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="evperiodic.again.html">EvPeriodic::again</a></div>
 <div class="up"><a href="book.ev.html">Ev</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.evperiodic" class="reference">
 <h1 class="title">The EvPeriodic class</h1>
 
 <div class="partintro"><p class="verinfo">(PECL ev &gt;= 0.2.0)</p>

  <div class="section" id="evperiodic.intro">
   <h2 class="title">简介</h2>
  <p class="para">
    Periodic watchers are also timers of a kind, but they are very versatile.
   </p>
   <p class="para">
    Unlike
    <a href="class.evtimer.html" class="classname">EvTimer</a>
    ,
    <strong class="classname">EvPeriodic</strong>
    watchers are not based on real time(or relative time, the physical time
    that passes) but on wall clock time(absolute time, calendar or clock). The
    difference is that wall clock time can run faster or slower than real
    time, and time jumps are not uncommon(e.g. when adjusting it).
   </p>
   <p class="para">
    <strong class="classname">EvPeriodic</strong>
    watcher can be configured to trigger after some specific point in time.
    For example, if an
    <strong class="classname">EvPeriodic</strong>
    watcher is configured to trigger
    <em class="emphasis">&quot;in 10 seconds&quot;</em>
    (e.g.
    <span class="methodname"><a href="evloop.now.html" class="methodname">EvLoop::now()</a></span>
    +
    <strong><code>10.0</code></strong>
    , i.e. an absolute time, not a delay), and the system clock is reset to
    <em class="emphasis">January of the previous year</em>
    , then it will take a year or more to trigger the event (unlike an
    <a href="class.evtimer.html" class="classname">EvTimer</a>
    , which would still trigger roughly
    <strong><code>10</code></strong>
    seconds after starting it as it uses a relative timeout).
   </p>
   <p class="para">
    As with timers, the callback is guaranteed to be invoked only when the
    point in time where it is supposed to trigger has passed. If multiple
    timers become ready during the same loop iteration then the ones with
    earlier time-out values are invoked before ones with later time-out values
    (but this is no longer true when a callback calls
    <span class="methodname"><a href="evloop.run.html" class="methodname">EvLoop::run()</a></span>
    recursively).
   </p>
  </div>

  <div class="section" id="evperiodic.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">EvPeriodic</strong>
     </span>
     <span class="ooclass">
      <span class="modifier">extends</span>
      <a href="class.evwatcher.html" class="classname">EvWatcher</a>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evperiodic.html#evperiodic.props.offset">$<var class="varname">offset</var></a></var>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evperiodic.html#evperiodic.props.interval">$<var class="varname">interval</var></a></var>
    ;</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.is-active">$<var class="varname">is_active</var></a></var>
    ;</div>
<div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.data">$<var class="varname">data</var></a></var>
    ;</div>
<div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.is-pending">$<var class="varname">is_pending</var></a></var>
    ;</div>
<div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.priority">$<var class="varname">priority</var></a></var>
    ;</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evperiodic.again.html" class="methodname">again</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">double</span>
   <span class="methodname"><a href="evperiodic.at.html" class="methodname">at</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><a href="evperiodic.construct.html" class="methodname">__construct</a></span>
    ( <span class="methodparam">
    <span class="type">double</span>
     <code class="parameter">$offset</code>
   </span>
   , <span class="methodparam">
    <span class="type">string</span>
     <code class="parameter">$interval</code>
   </span>
   , <span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$reschedule_cb</code>
   </span>
   , <span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>
   [, <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$data</code>
    <span class="initializer"> = <strong><code>NULL</code></strong></span>
   </span>
   [, <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$priority</code>
    <span class="initializer"> = 0</span>
   </span>
  ]] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">final</span>
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">EvPeriodic</span>
   <span class="methodname"><a href="evperiodic.createstopped.html" class="methodname">createStopped</a></span>
    ( <span class="methodparam">
    <span class="type">double</span>
     <code class="parameter">$offset</code>
   </span>
   , <span class="methodparam">
    <span class="type">double</span>
     <code class="parameter">$interval</code>
   </span>
   , <span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$reschedule_cb</code>
   </span>
   , <span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>
   [, <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$data</code>
    <span class="initializer"> = <strong><code>NULL</code></strong></span>
   </span>
   [, <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$priority</code>
    <span class="initializer"> = 0</span>
   </span>
  ]] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evperiodic.set.html" class="methodname">set</a></span>
    ( <span class="methodparam">
    <span class="type">double</span>
     <code class="parameter">$offset</code>
   </span>
   , <span class="methodparam">
    <span class="type">double</span>
     <code class="parameter">$interval</code>
   </span>
   )</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">int</span>
   <span class="methodname"><a href="evwatcher.clear.html" class="methodname">EvWatcher::clear</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">abstract</span>
   <span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.construct.html" class="methodname">EvWatcher::__construct</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evwatcher.feed.html" class="methodname">EvWatcher::feed</a></span>
    ( <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$revents</code>
   </span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">EvLoop</span>
   <span class="methodname"><a href="evwatcher.getloop.html" class="methodname">EvWatcher::getLoop</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evwatcher.invoke.html" class="methodname">EvWatcher::invoke</a></span>
    ( <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$revents</code>
   </span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span>
   <span class="methodname"><a href="evwatcher.keepalive.html" class="methodname">EvWatcher::keepalive</a></span>
    ([ <span class="methodparam">
    <span class="type">bool</span>
     <code class="parameter">$value</code>
   </span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evwatcher.setcallback.html" class="methodname">EvWatcher::setCallback</a></span>
    ( <span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evwatcher.start.html" class="methodname">EvWatcher::start</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">void</span>
   <span class="methodname"><a href="evwatcher.stop.html" class="methodname">EvWatcher::stop</a></span>
    ( <span class="methodparam">void</span>
   )</div>

   }</div>

  </div>

  <div class="section" id="evperiodic.props">
   <h2 class="title">属性</h2>
   <dl>

    
     <dt id="evperiodic.props.offset">
      <var class="varname"><var class="varname">offset</var></var>
     </dt>

     <dd>

      <p class="para">
       When repeating, this contains the offset value, otherwise this is the
       absolute point in time(the offset value passed to
       <span class="methodname"><a href="evperiodic.set.html" class="methodname">EvPeriodic::set()</a></span>
       , although
       <em class="emphasis">libev</em>
       might modify this value for better numerical stability).
      </p>
     </dd>

    
    
     <dt id="evperiodic.props.interval">
      <var class="varname"><var class="varname">interval</var></var>
     </dt>

     <dd>

      <p class="para">
       The current interval value. Can be modified any time, but changes only
       take effect when the periodic timer fires or
       <span class="methodname"><a href="evperiodic.again.html" class="methodname">EvPeriodic::again()</a></span>
       is being called.
      </p>
     </dd>

    
   </dl>

  </div>

 </div>

 


























<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="evperiodic.again.html">EvPeriodic::again</a> — Simply stops and restarts the periodic watcher again.</li><li><a href="evperiodic.at.html">EvPeriodic::at</a> — Returns the absolute time that this
  watcher is supposed to trigger next</li><li><a href="evperiodic.construct.html">EvPeriodic::__construct</a> — Constructs EvPeriodic watcher object</li><li><a href="evperiodic.createstopped.html">EvPeriodic::createStopped</a> — Create a stopped EvPeriodic watcher</li><li><a href="evperiodic.set.html">EvPeriodic::set</a> — Configures the watcher</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="evloop.verify.html">EvLoop::verify</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="evperiodic.again.html">EvPeriodic::again</a></div>
 <div class="up"><a href="book.ev.html">Ev</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
